import { type RouteRecordRaw } from 'vue-router'
import Home from '../views/home/index.vue'
import TabBar from '../components/tab-bar/index.vue'
import NavBar from '../components/nav-bar/index.vue'


const Category = () => import('../views/category/index.vue')
const Cart = () => import('../views/cart/index.vue')
const Mine = () => import('../views/mine/index.vue')
const Login = () => import('../views/login/index.vue')
const Register = () => import('@/views/register/index.vue')
const Search = () => import('@/views/search/index.vue')
const Detail = () => import('@/views/detail/index.vue')
const List = () => import('@/views/list/index.vue')
const Order = () => import('@/views/order/index.vue')
const Confirm = () => import('@/views/confirm/index.vue')

const routes: RouteRecordRaw[] = [
    {
        path: '/',
        redirect: '/home',
    },
    {
        path: '/home',
        components: {
            default: Home,
            footer: TabBar,
        },
        meta: {
            icon: 'home-o',
            title: '首页',
            inTabbar: true, //放置在tabbar中,如果不写这一项，就会动态的删除tab-bar.vue 中的相应项
        }
    },
    {
        path: '/category',
        components: {
            header: NavBar,
            default: Category,
            footer: TabBar,
        },
        meta: {
            icon: 'list-switch',
            title: '分类',
            inTabbar: true,
        }
    },
    {
        path: '/cart',
        components: {
            header: NavBar,
            default: Cart,
            footer: TabBar,
        },
        meta: {
            icon: 'shopping-cart-o',
            title: '购物车',
            inTabbar: true,
        }
    },
    {
        path: '/mine',
        components: {
            header: NavBar,
            default: Mine,
            footer: TabBar,
        },
        meta: {
            icon: 'user-o',
            title: '我的',
            inTabbar: true,
            permission: true,//登录需要权限
        }
    },
    {
        path: '/login',
        components: {
            header: NavBar,
            default: Login,
        },
        meta: {
            title: '用户登录',
        }
    },
    {
        path: '/register',
        components: {
            header: NavBar,
            default: Register,
        },
        meta: {
            title: '用户注册'
        }
    },
    {
        path: '/search',
        components: {
            header: NavBar,
            default: Search,
        },
        meta: {
            title: '搜索'
        }
    },
    {
        path: '/detail/:id',
        name: 'detail',
        components: {
            header: NavBar,
            default: Detail,
        },
        meta: {
            title: '商品详情'
        },
    },
    {
        path: '/list',
        name: 'list',
        components: {
            header: NavBar,
            default: List,
        },
        meta: {
            title: '商品列表'
        },
    },
    {
        path: '/order',
        name: 'order',
        components: {
            header: NavBar,
            default: Order,
        },
        meta: {
            title: '历史订单',
            permission: true,//登录需要权限
        },
    },
    {
        path: '/confirm',
        name: 'confirm',
        components: {
            header: NavBar,
            default: Confirm,
        },
        meta: {
            title: '确认订单',
            permission: true,//登录需要权限
        },
    },
]

export default routes
